package B.链表;

public class _83_删除排序链表中的重复元素 {
    /**
     * 自解：直接法
     * @param head
     * @return
     */
    public ListNode deleteDuplicates(ListNode head) {


        ListNode cur =head;
        while ( cur != null &&cur.next !=  null){ //先判断cur是否有 要不然容易空指针异常
            if (cur.val == cur.next.val ){
                cur.next = cur.next.next;
                if (cur.next == null){
                    return head;
                }

            }else {
                cur = cur.next;
            }

        }

        return head;


    }

}
